<?php

 if (!defined('BASEPATH'))
     exit('No esta permitido el acceso directo');

 class Generadorpassword  {

     private $length, $strength;



     public function __Construct($p_length=9, $p_strength=0) {
         $this->set_length($p_length);
         $this->set_strength($p_strength);
     }



     public function set_length($p_length) {
         $this->length = $p_length;


     }



     public function set_strength($p_strength) {
         $this->strength = $p_strength;


     }



     public function get_lenght() {
         return $this->length;


     }



     public function get_strength() {
         return $this->strength;


     }



     public function generatePassword($length=5, $strength=4) {
         $vowels = 'aeuy';
         $consonants = 'bdghjmnpqrstvz';
         if ($strength & 1) {
             $consonants .= 'BDGHJLMNPQRSTVWXZ';
         }
         if ($strength & 2) {
             $vowels .= "AEUY";
         }
         if ($strength & 4) {
             $consonants .= '23456789';
         }
         if ($strength & 8) {
             $consonants .= '@#$%';
         }

         $password = '';
         $alt = time() % 2;
         for ($i = 0; $i < $length; $i++) {
             if ($alt == 1) {
                 $password .= $consonants[(rand() % strlen($consonants))];
                 $alt = 0;
             } else {
                 $password .= $vowels[(rand() % strlen($vowels))];
                 $alt = 1;
             }
         }
         return $password;


     }



 }

 